package com.yxj.securityhello.domain.vo;

import com.yxj.securityhello.domain.Svsuser;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @author yangxuejiao
 * @description
 * @createDate 2025/11/2 18:14
 */

@Data
@NoArgsConstructor
public class LoginUser implements UserDetails {

    private Svsuser user;

    public LoginUser(Svsuser user) {
        this.user = user;
    }

    //权限列表
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return List.of();
    }

    //返回密码
    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getUserName();
    }

    //账号是否未过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    //账号是否未超时
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
